/**
 * 简单的格子算法
 */
import ccxt from 'ccxt';
//import mathUtils from 'mathUtils'
// import { add, subtract } from './mathUtils.js';
import {cancel_all_order} from './ccxt_utils.mjs'

// //esm
// import {version, exchanges} from 'ccxt';
// console.log(version, Object.keys(exchanges));

(async function () {

    let okx111 = new ccxt.okx({
        'apiKey':"a5d30ef3-e7e2-4bff-b2ea-624ecc45d615",
        'secret': 'A52DAB82A4BD5570AFB4D1C90693F983',
        'enableRateLimit': true,
        'password':"Arbiter2024#",
    }
    );
    
    // BEGIN proxy
    okx111.httpProxy = 'http://127.0.0.1:33210/';// http与https只能用一个， 不能同时设置
    // okx111.httpsProxy = 'https://127.0.0.1:33210/'
    // END proxy

    // var xxx=  await okx111.loadMarkets();
    // console.log(xxx);

    console.log("清理挂单：");
    await cancel_all_order(okx111);

    
    /**
     * 取比特币总量
     */
    var inventoryBTC = await okx111.fetch_balance();
    // console.log(inventoryBTC);
    // console.log(inventoryBTC.BTC);
    console.log("当前总比特币：",inventoryBTC.BTC.total);
    console.log("当前总USTC：",inventoryBTC.USDC.total);

    /**
     * 取比特币对应USDC价格
     */
    var price = await okx111.fetch_ticker('BTC/USDC');
    console.log("当前比特币价格：", price.ask);// 价格参数很多， 看不懂

    /**
     * 手头上比特币总价
     */
    console.log("比特币总值：",inventoryBTC.BTC.total*price.ask);


}) ();

/**

备注名:
ReadOnly
密码短语
Arbiter2024#

 */